package com.advertisementsystem.task;

import com.advertisementsystem.Servie.BillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class BillTask {

    @Autowired
    private BillService billService;

    /**
     * 每天凌晨1点检查并更新逾期账单
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void updateOverdueBills() {
        log.info("开始执行更新逾期账单任务");
        try {
            billService.updateOverdueBills();
            log.info("更新逾期账单任务执行完成");
        } catch (Exception e) {
            log.error("更新逾期账单任务执行失败", e);
        }
    }
}